/*
 * HAPSIEMenuPrincipal.java
 *
 * Created on 23/01/2012, 07:50:32 PM
 */
package interfaz.Intro;

import interfaz.Informacion.CopyRight;
import interfaz.Informacion.Intro;
import interfaz.Resultados.rGeneral;
import interfaz.checkList.CheckList;
import interfaz.checkList.ConfigCheckList;
import interfaz.gestionAreas.GestionDeAreas;
import interfaz.gestionEstandares.GestionDeEstandares;
import javax.swing.JDialog;
import moduloAreas.ManejadorAreas;
import moduloEstandares.ManejadorEstandares;
import moduloEstandares.ManejadorRelacionesAplica;
import usoHAPSIE.HAPSIEApp;

/**
 *
 * @author Erika Berenice Hernández Angulo
 */
public class MenuPrincipal extends javax.swing.JDialog {

    private JDialog gestionDeAreas;   
    private JDialog gestionDeEstandares ;
    private JDialog checkList;
    private JDialog Intro;
    private JDialog CopyRight;
    private JDialog resultados;
    private JDialog configuraCheckList;
    public static ManejadorAreas manAreas = new ManejadorAreas(HAPSIEApp.servicioConexion);
    public static ManejadorEstandares manEstandares = new ManejadorEstandares(HAPSIEApp.servicioConexion);
    public static ManejadorRelacionesAplica manRelaciones = new ManejadorRelacionesAplica(HAPSIEApp.servicioConexion);
    
    /** Creates new form HAPSIEMenuPrincipal */

     public MenuPrincipal(SeleccionEstandar aThis) {
        super(aThis);
        initComponents();
        adaptaMenu();
    }
     
     private void adaptaMenu() {
        if(!HAPSIEApp.trabajarConAreas){
            botonGestionDeAreas.setVisible(false);
        } else {
            if(!manAreas.hayAreas()) {
                botonGestionDeEstandares.setEnabled(false);
            } else {
                botonGestionDeEstandares.setEnabled(true);
            }
        }
     }
     
     public void refrescaMenu() {
         adaptaMenu();
     }
     
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        botonGestionDeAreas = new javax.swing.JButton();
        botonGestionDeEstandares = new javax.swing.JButton();
        botonCheckList = new javax.swing.JButton();
        botonResultados = new javax.swing.JButton();
        botonSalir = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        botonIntro = new javax.swing.JButton();
        botonCopyRigth = new javax.swing.JButton();
        barraDeMenu = new javax.swing.JMenuBar();
        file = new javax.swing.JMenu();
        edit = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(MenuPrincipal.class);
        setTitle(resourceMap.getString("menuPrincipal.title")); // NOI18N
        setName("menuPrincipal"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        botonGestionDeAreas.setFont(resourceMap.getFont("botonGestionDeAreas.font")); // NOI18N
        botonGestionDeAreas.setText(resourceMap.getString("botonGestionDeAreas.text")); // NOI18N
        botonGestionDeAreas.setName("botonGestionDeAreas"); // NOI18N
        botonGestionDeAreas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonGestionDeAreasActionPerformed(evt);
            }
        });

        botonGestionDeEstandares.setFont(resourceMap.getFont("botonGestionDeEstandares.font")); // NOI18N
        botonGestionDeEstandares.setText(resourceMap.getString("botonGestionDeEstandares.text")); // NOI18N
        botonGestionDeEstandares.setName("botonGestionDeEstandares"); // NOI18N
        botonGestionDeEstandares.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonGestionDeEstandaresActionPerformed(evt);
            }
        });

        botonCheckList.setFont(resourceMap.getFont("botonCheckList.font")); // NOI18N
        botonCheckList.setText(resourceMap.getString("botonCheckList.text")); // NOI18N
        botonCheckList.setName("botonCheckList"); // NOI18N
        botonCheckList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonCheckListActionPerformed(evt);
            }
        });

        botonResultados.setFont(resourceMap.getFont("botonResultados.font")); // NOI18N
        botonResultados.setText(resourceMap.getString("botonResultados.text")); // NOI18N
        botonResultados.setName("botonResultados"); // NOI18N
        botonResultados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonResultadosActionPerformed(evt);
            }
        });

        botonSalir.setFont(resourceMap.getFont("botonSalir.font")); // NOI18N
        botonSalir.setText(resourceMap.getString("botonSalir.text")); // NOI18N
        botonSalir.setName("botonSalir"); // NOI18N
        botonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSalirActionPerformed(evt);
            }
        });

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/interfaz/resources/NegotegiaIcono.png"))); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        botonIntro.setFont(resourceMap.getFont("botonIntro.font")); // NOI18N
        botonIntro.setText(resourceMap.getString("botonIntro.text")); // NOI18N
        botonIntro.setName("botonIntro"); // NOI18N
        botonIntro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonIntroActionPerformed(evt);
            }
        });

        botonCopyRigth.setFont(resourceMap.getFont("botonCopyRigth.font")); // NOI18N
        botonCopyRigth.setText(resourceMap.getString("botonCopyRigth.text")); // NOI18N
        botonCopyRigth.setName("botonCopyRigth"); // NOI18N
        botonCopyRigth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonCopyRigthActionPerformed(evt);
            }
        });

        barraDeMenu.setName("barraDeMenu"); // NOI18N

        file.setName("file"); // NOI18N
        file.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
               // fileActionPerformed(evt);
            }
        });
        barraDeMenu.add(file);

        edit.setName("edit"); // NOI18N
        barraDeMenu.add(edit);

        setJMenuBar(barraDeMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(169, 169, 169)
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                .addGap(50, 50, 50)
                .addComponent(jLabel7)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(199, 199, 199)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(botonSalir, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(botonIntro, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(botonCopyRigth, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(botonGestionDeAreas, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(botonGestionDeEstandares, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(botonCheckList, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(botonResultados, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
                .addGap(206, 206, 206))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(60, 60, 60)
                .addComponent(botonIntro)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botonCopyRigth)
                .addGap(58, 58, 58)
                .addComponent(botonGestionDeAreas, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(botonGestionDeEstandares, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(botonCheckList, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(botonResultados, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40)
                .addComponent(botonSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void botonGestionDeAreasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGestionDeAreasActionPerformed
    gestionDeAreas = new GestionDeAreas(this);
    setVisible(false);
    gestionDeAreas.setLocationRelativeTo(this);
    gestionDeAreas.setVisible(true);    
}//GEN-LAST:event_botonGestionDeAreasActionPerformed

private void botonGestionDeEstandaresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGestionDeEstandaresActionPerformed
    gestionDeEstandares = new GestionDeEstandares(this);
    setVisible(false);
    gestionDeEstandares.setLocationRelativeTo(this);
    gestionDeEstandares.setVisible(true);
}//GEN-LAST:event_botonGestionDeEstandaresActionPerformed

private void botonCheckListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonCheckListActionPerformed
    if(HAPSIEApp.trabajarConAreas) {
        configuraCheckList = new ConfigCheckList(this);
        setVisible(false);
        configuraCheckList.setLocationRelativeTo(this);
        configuraCheckList.setVisible(true);
    } else {
        checkList = new CheckList(this, -1);
        setVisible(false);
        checkList.setLocationRelativeTo(this);
        checkList.setVisible(true);
    }
}//GEN-LAST:event_botonCheckListActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

 HAPSIEApp.servicioConexion.cierraSesion();
 System.exit(0);
    
}//GEN-LAST:event_formWindowClosing

private void botonResultadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonResultadosActionPerformed
  resultados = new rGeneral(this);
  setVisible(false);
  resultados.setLocationRelativeTo(this);
  resultados.setVisible(true);
    
}//GEN-LAST:event_botonResultadosActionPerformed

private void botonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSalirActionPerformed
  HAPSIEApp.servicioConexion.cierraSesion();
  System.exit(0);
}//GEN-LAST:event_botonSalirActionPerformed

private void botonIntroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonIntroActionPerformed
    Intro = new Intro(this);
    setVisible(false);
    Intro.setLocationRelativeTo(this);  
    Intro.setVisible(true);
    
    
}//GEN-LAST:event_botonIntroActionPerformed

private void botonCopyRigthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonCopyRigthActionPerformed
    CopyRight = new CopyRight(this);
    setVisible(false);
    CopyRight.setLocationRelativeTo(this);  
    CopyRight.setVisible(true);
}//GEN-LAST:event_botonCopyRigthActionPerformed

    /**
     * @param args the command line arguments
     */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar barraDeMenu;
    private javax.swing.JButton botonCheckList;
    private javax.swing.JButton botonCopyRigth;
    private javax.swing.JButton botonGestionDeAreas;
    private javax.swing.JButton botonGestionDeEstandares;
    private javax.swing.JButton botonIntro;
    private javax.swing.JButton botonResultados;
    private javax.swing.JButton botonSalir;
    private javax.swing.JMenu edit;
    private javax.swing.JMenu file;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel7;
    // End of variables declaration//GEN-END:variables

 
}
